package smartcode.privacy;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.LifecycleOwner;


/**
 * @author DIYUN
 * @date 2019/4/22.
 * description：activity基类
 */
public abstract class BaseActivity extends FragmentActivity {
    public Object mIntentData;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        //设置布局
        setContentView(intiLayout());
        //绑定view
        //设置状态栏字体黑色
        initToolBar(true);
        //传递数据
        initIntentData();

        //初始化控件
        initView();
        //设置数据
        initData();
        initVM();
    }

    public void initToolBar(boolean statusBarFontBlack) {
        //沉浸式

    }

    protected BaseActivity getAty() {
        return this;
    }

    /**
     * 设置布局
     *
     * @return
     */
    public abstract int intiLayout();

    /**
     * 初始化布局
     */
    public abstract void initView();

    /**
     * 设置数据
     */
    public void initData() {
    }

    /**
     * 标题返回箭头点击事件
     *
     * @param var1
     */
    public void back(View var1) {
        onBackPressed();
    }

    @Override
    protected void onDestroy() {

        super.onDestroy();
    }

    /**
     * 显示进度条
     */
    protected void showLoadingDialog() {

    }

    protected void showLoadingDialog(String tip) {

    }

    /**
     * 隐藏进度条
     */
    protected void dismissLoadingDialog() {

    }

    /**
     * 传递数据初始化
     */
    private void initIntentData() {
        this.mIntentData = this.getIntent().getSerializableExtra("Data");
    }


    public Object getIntentData() {
        return this.mIntentData;
    }

    public void startAct(Activity act, Class cls) {
        this.startAct(act, cls, (Object) null, -1);
    }

    public void startAct(Activity act, Class cls, Object obj) {
        this.startAct(act, cls, obj, -1);
    }

    protected void startAct(Activity act, Class cls, Object obj, int requestCode) {
    }

    /**
     * //弹出吐司
     *
     * @param msg         内容
     * @param requestCode 弹出框样式
     */
    public void showToast(final String msg, final int requestCode) {
    }

    /**
     * 打印日志
     *
     * @param msg
     */
    protected void showLog(final String msg){
    }

    public void initVM() {

    }

    public static boolean levehint;

    @Override
    public void onResume() {
        super.onResume();
        if (levehint) {
            Class clz = null;
            try {
                clz = Class.forName("com.dy.yzjs.HomeKeyActivity");
            } catch (ClassNotFoundException e) {


            }
            startAct(this, clz);
            levehint = false;

        }
    }


    @Override
    public void onPause() {
        super.onPause();
    }


}
